package com.itheima.test.customer;

public class Cooker extends Thread{
    @Override
    public void run() {
        while(true){
            synchronized (Desk.lock){
                if(Desk.HamburgerNumber == 0){
                    break;
                }else{
                    if(Desk.flag){//桌子上有汉堡
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }else{//桌子上无汉堡
                        System.out.println("米其林高级汉堡扒厨师正在做汉堡");
                        Desk.flag = true;//汉堡状态为有
                        Desk.lock.notifyAll();//叫醒吃货
                    }
                }
            }
        }
    }
}
